﻿namespace OAuth.Providers.ETrade
{

    internal static class Settings
    {

        /// <summary>Gets the Consumer Key.</summary>
        public static string ConsumerKey { get; internal set; }
        /// <summary>Gets the Consumer Secret.</summary>
        public static string ConsumerSecret { get; internal set; }
        /// <summary>Gets the Connection mode.</summary>
        public static ConnectionModes ConnectionMode { get; internal set; }

        private const string ETRADE_SERVER_PRODUCTION = "https://etws.etrade.com";
        private const string ETRADE_SERVER_SANDBOX = "https://etwssandbox.etrade.com";

        #region Authorization URLs

        internal static string RequestTokenUrl { get { return "https://etws.etrade.com/oauth/request_token"; } }
        internal static string AuthorizeUrl { get { return "https://us.etrade.com/e/t/etws/authorize"; } }
        internal static string AccessTokenUrl { get { return "https://etws.etrade.com/oauth/access_token"; } }
        internal static string RenewTokenUrl { get { return "https://etws.etrade.com/oauth/renew_access_token"; } }
        internal static string RevokeTokenUrl { get { return "https://etws.etrade.com/oauth/revoke_access_token"; } }

        #endregion

        #region Account URLs

        internal static string AccountListUrl
        {
            get
            {
                if (ConnectionMode == ConnectionModes.Production)
                    return string.Concat(ETRADE_SERVER_PRODUCTION, "/accounts/rest/accountlist");

                return string.Concat(ETRADE_SERVER_SANDBOX, "/accounts/sandbox/rest/accountlist");
            }
        }

        internal static string AccountBalanceUrl
        {
            get
            {
                if (ConnectionMode == ConnectionModes.Production)
                    return string.Concat(ETRADE_SERVER_PRODUCTION, "/accounts/rest/accountbalance");

                return string.Concat(ETRADE_SERVER_SANDBOX, "/accounts/sandbox/rest/accountbalance");
            }
        }

        internal static string AccountPositionsUrl
        {
            get
            {
                if (ConnectionMode == ConnectionModes.Production)
                    return string.Concat(ETRADE_SERVER_PRODUCTION, "/accounts/rest/accountpositions");

                return string.Concat(ETRADE_SERVER_SANDBOX, "/accounts/sandbox/rest/accountpositions");
            }
        }

        internal static string AccountAlertsUrl
        {
            get
            {
                if (ConnectionMode == ConnectionModes.Production)
                    return string.Concat(ETRADE_SERVER_PRODUCTION, "/accounts/rest/alerts");

                return string.Concat(ETRADE_SERVER_SANDBOX, "/accounts/sandbox/rest/alerts");
            }
        }

        #endregion

        #region Market URLs

        internal static string MarketQuoteUrl
        {
            get
            {
                if (ConnectionMode == ConnectionModes.Production)
                    return string.Concat(ETRADE_SERVER_PRODUCTION, "/market/rest/quote");

                return string.Concat(ETRADE_SERVER_SANDBOX, "/market/sandbox/rest/quote");
            }
        }

        #endregion

        //public const string URL_OPTIONCHAINS = "/market/rest/optionchains');
        //public const string URL_MARKETINDICES = "/market/rest/marketindices');
        //public const string URL_PRODUCTLOOKUP = "/market/rest/productlookup');
        //public const string URL_EXPIRYDATES',			ETRADE_SERVER . '/market/rest/optionexpiredate');

        //public const string URL_ORDERLIST',			ETRADE_SERVER . '/order/rest/orderlist');

        //public const string URL_PL_EQ_ORDER',			ETRADE_SERVER .'/order/rest/placeequityorder');
        //public const string URL_PL_OP_ORDER',			ETRADE_SERVER .'/order/rest/placeoptionorder');
        //public const string URL_PR_EQ_ORDER',			ETRADE_SERVER .'/order/rest/previewequityorder');
        //public const string URL_PR_OP_ORDER',			ETRADE_SERVER .'/order/rest/previewoptionorder');
        //public const string URL_PR_CH_EQ_ORDER',		ETRADE_SERVER .'/order/rest/previewchangeequityorder');
        //public const string URL_PL_CH_EQ_ORDER',		ETRADE_SERVER .'/order/rest/placechangeequityorder');
        //public const string URL_PR_CH_OP_ORDER',		ETRADE_SERVER .'/order/rest/previewchangeoptionorder');
        //public const string URL_PL_CH_OP_ORDER',		ETRADE_SERVER .'/order/rest/placechangeoptionorder');
        //public const string URL_CANCEL_ORDER',		ETRADE_SERVER .'/order/rest/cancelorder');

    }

}